package com.tsunami.authority.entity.auth;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tsunami.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;


/**
 * <p>
 * 菜单表
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
@TableName("tnm_auth_menu")
@ApiModel(value="Menu", description="菜单")
public class Menu extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "租户号")
    private Long tenantId;

    @ApiModelProperty(value = "菜单名称")
    @NotEmpty(message = "菜单名称不能为空")
    @Length(max = 20, message = "菜单名称长度不能超过20")
    @TableField(value = "name")
    private String name;

    @ApiModelProperty(value = "功能描述")
    @TableField(value = "describe_")
    private String describe;

    @ApiModelProperty(value = "是否是公开菜单")
    @TableField(value = "s_public")
    private Boolean sPublic;

    @ApiModelProperty(value = "对应路由path")
    @TableField(value = "path")
    private String path;

    @ApiModelProperty(value = "对应路由组件")
    @TableField(value = "component")
    private String component;

    @ApiModelProperty(value = "是否启用")
    @TableField(value = "s_enable")
    private Boolean sEnable;

    @ApiModelProperty(value = "排序")
    @TableField(value = "sort_value")
    private Integer sortValue;

    @ApiModelProperty(value = "菜单图标")
    @TableField(value = "icon")
    private String icon;

    @ApiModelProperty(value = "菜单分组")
    @TableField(value = "group_")
    private String group;

    @ApiModelProperty(value = "应用编码")
    @TableField(value = "app_code")
    private String appCode;

    @ApiModelProperty(value = "父级菜单ID")
    @TableField(value = "parent_id")
    private Long parentId;

    @Builder
    public Menu(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime,
                String name, String describe, Boolean sPublic, String path, String component,
                Boolean sEnable, Integer sortValue, String icon, String group, Long parentId) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.name = name;
        this.describe = describe;
        this.sPublic = sPublic;
        this.path = path;
        this.component = component;
        this.sEnable = sEnable;
        this.sortValue = sortValue;
        this.icon = icon;
        this.group = group;
        this.parentId = parentId;
    }
}
